package com.hxx.config;

import com.hxx.ai.LegalAssiatant;
import com.hxx.ai.NumberExtractor;
import com.hxx.ai.PersonExtractor;
import com.hxx.ai.SentimentAnalyzer;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {

    @Bean
    public ChatLanguageModel chatLanguageModel(){
        return OllamaChatModel
                .builder()
                .modelName("qwen2.5:3b")
                .baseUrl("http://localhost:11434")
                .build();
    }

    @Bean
    public LegalAssiatant legalAssiatant(ChatLanguageModel chatLanguageModel){
        return AiServices.create(LegalAssiatant.class,chatLanguageModel);
    }

    //数字提取器
    @Bean
    public NumberExtractor numberExtractor(ChatLanguageModel chatLanguageModel){
        return AiServices.create(NumberExtractor.class, chatLanguageModel);
    }

    //创建情感分析器
    @Bean
    public SentimentAnalyzer sentimentAnalyzer(ChatLanguageModel chatLanguageModel){
        return AiServices.create(SentimentAnalyzer.class, chatLanguageModel);
    }

    //人名提取器
    @Bean
    public PersonExtractor personExtractor(ChatLanguageModel chatLanguageModel){
        return AiServices.create(PersonExtractor.class, chatLanguageModel);
    }

}
